#pragma once

#include "IDBSession.h"
#include "sqlite3.h"
#include <vector>
#include <string>

/**
 * @file SQLiteSession.h
 *
 * @brief SQLite implementation of database interface
 *
 * @author cygia.com
 * Contact: lance.liao@cygia.com
 *
 */
class CSQLiteSession :
	public IDBSession
{
public:
	CSQLiteSession();
	~CSQLiteSession();

	int Connect(CDBConfig config);
	int Close() noexcept;
	int IsConnected();

	int GetTables(std::vector<std::string>& tables);

	int BeginTransaction();
	int CommitTransaction();
	int RollBackTransaction();

	int ExecuteScalar(std::string sql, std::string& result);
	int ExcuteSelect(std::string sql, std::vector<std::string>& results, int& col, int& row);
	int ExcuteNonQuery(std::string sql);

private:
	CDBConfig _dbConfig;
	sqlite3* _pConn;
};

